package com.usian.user.controller;

import com.usian.common.vo.ResponseResult;
import com.usian.user.service.IndexService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/v1/index")
@Slf4j
public class IndexController {

    @Autowired
    private IndexService indexService;



    @GetMapping("/myCompetition")
    public ResponseResult myCompetition(HttpServletRequest request){
        String token = request.getHeader("token");
        log.info("=============:{}",token);

        return indexService.myCompetition(token);
    }

    @GetMapping("/myTrain")
    public ResponseResult myTrain(HttpServletRequest request){
        String token = request.getHeader("token");
        return indexService.myTrain(token);
    }

    @GetMapping("myCourse")
    public ResponseResult myCourse(HttpServletRequest request){
        String token = request.getHeader("token");
        return indexService.myCourse(token);
    }

    @GetMapping("hotCourse")
    public ResponseResult hotCourse(){
        return indexService.hotCourse();
    }

    @GetMapping("haslike")
    public ResponseResult haslike(HttpServletRequest request,Integer id){
        String token = request.getHeader("token");
        return indexService.haslike(token,id);
    }

    @GetMapping("getNewestClass")
    public ResponseResult getNewestClass (){
        return indexService.getNewestClass();
    }

    @GetMapping("hasNewestLike")
    public ResponseResult hasNewestLike(HttpServletRequest request,Integer id){
        String token = request.getHeader("token");
        return indexService.hasNewestLike(token,id);
    }

    @GetMapping("getNewestTrain")
    public ResponseResult getNewestTrain(){
        return indexService.getNewestTrain();
    }

    @GetMapping("getNewestExam")
    public ResponseResult getNewestExam(){
        return indexService.getNewestExam();
    }

}
